# Maintainer: leso-kn <info@lesosoftware.com>
pkgname=piper-phonemize
_pkgver=2023.11.14-4
pkgver=${_pkgver/-/.}
pkgrel=1
pkgdesc="C++ library for converting text to phonemes for piper-tts"
url="https://github.com/rhasspy/piper-phonemize"
# x86, riscv64, s390x: not supported by onnxruntime
arch="all !x86 !riscv64 !s390x"
license="MIT AND GPL-3.0-only"
depends_dev="$pkgname-libs"
makedepends="
	cmake
	espeak-ng-dev
	onnxruntime-dev
	samurai
	"
subpackages="
	$pkgname-dev
	$pkgname-libs:_libs
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/rhasspy/piper-phonemize/archive/refs/tags/$_pkgver.tar.gz
	no-rpath.patch
	use-system-espeak-ng.patch
	use-system-onnxruntime.patch
	add-pkgconfig-support.patch
	"
builddir="$srcdir"/piper-phonemize-$_pkgver

case "$CARCH" in
	riscv64) options="!check";;
esac

build() {
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

_libs() {
	amove usr/lib
}

sha512sums="
0a5e07c98da91fd887a9082d42b7b884277fcb02af3116c71fe0900457528dd432abe2634c837f8fe8b47c718ff9dbc4003ce36d502d6a58c7ecc61fab015776  piper-phonemize-2023.11.14.4.tar.gz
793c4e6b2666bce8840474cc1c927d459ac9e0b8d752777aa4dd17e5b9a6aaa242ef44a9b88d18bc96886f58be4dcb3c8d885dfc26c92d9d0d1fc08626d6da77  no-rpath.patch
7afc438cb3c2af3c1b502a5d9f2360efe26636c8ae346432bc749c20ada3d29e57cafaa92c0779ce3954353f70e9f82bf03e7010019b940f7c17695c5c0e5ed1  use-system-espeak-ng.patch
7288e01ec021d5c14fb39769ca8f219f95d5781301504ce7cd6b0bc4cfa590f60ebfb9293a741972768ac5a6e066d462ea49ba1f141aad98276ff1a31e07ab8c  use-system-onnxruntime.patch
1cb5e8c0f6bdfc53e6de7422c89b0561586e28fd9c0692d87578e47d1f903b25387c887f23a81621f128a2cd0306a9ef2b5f9cf9d57b25d6a9402ef09e62d5ab  add-pkgconfig-support.patch
"
